package com.nbsaas.boot.data.rest.convert;

import com.nbsaas.boot.data.data.entity.QueryTemplate;
import com.nbsaas.boot.data.api.domain.request.QueryTemplateRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.jpa.data.entity.User;
            import com.nbsaas.boot.data.data.entity.QueryCatalog;
            import com.nbsaas.boot.jpa.data.entity.User;

/**
* 请求对象转换成实体对象
*/

public class QueryTemplateEntityConvert  implements Converter<QueryTemplate, QueryTemplateRequest> {

    @Override
    public QueryTemplate convert(QueryTemplateRequest source) {
        QueryTemplate result = new QueryTemplate();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getModifier()!=null){
                    User modifier =new User();
                    modifier.setId(source.getModifier());
                    result.setModifier(modifier);
                    }
                    if(source.getQueryCatalog()!=null){
                    QueryCatalog queryCatalog =new QueryCatalog();
                    queryCatalog.setId(source.getQueryCatalog());
                    result.setQueryCatalog(queryCatalog);
                    }
                    if(source.getCreator()!=null){
                    User creator =new User();
                    creator.setId(source.getCreator());
                    result.setCreator(creator);
                    }
        return result;
    }
}

